﻿@using Janus.BaseEntitys;
@using Janus.Mes.WebClient;

@model IEnumerable<ModuleDTO>
@{
    var currentTabs = new List<ModuleDTO>();
    if (Model == null || Model.Count() == 0)
    {
        currentTabs = ViewData["CurrentTabs"] as List<ModuleDTO>;
    }
    else
    {
        currentTabs = new List<ModuleDTO>(Model);
    }
    //获取父级的QueryString
    string querystring = Html.UrlQuerys();
}
@if (currentTabs != null)
{
    var index = currentTabs.Max(c => c.Indexs);
    <div class="tabs" currentindex="@index" eventtype="click">
        <div class="tabsHeader">

            <div class="tabsHeaderContent">
                <ul>
                    @for (int i = 0; i < currentTabs.Count; i++)
                    {
                        string url = Html.FormateUrl(currentTabs[i].Url, currentTabs[i].ID, querystring);
                        <li id="li@{@currentTabs[i].ID}">
                            <a href="@url" id="a@{@currentTabs[i].ID}" class="j-ajax @(string.Compare(currentTabs[i].Fresh,"true",true)>=0?"isRefresh":"")" isrefresh="@(currentTabs[i].Fresh)">
                                <span>@(currentTabs[i].ModuleName)</span>
                            </a>
                        </li>
                    }
                </ul>
            </div>

        </div>
        <div class="tabsContent">
            @for (int i = 0; i < currentTabs.Count; i++)
            {

                if (i == index)
                {
                    string url = Html.FormateUrl(currentTabs[i].Url, currentTabs[i].ID);
                    <div id="div@{@currentTabs[0].ID}">
                        @{Html.RenderActionUrl(url);}
                    </div>
                }
                else
                {
                    <div id="div@{@currentTabs[i].ID}"></div>
                }
            }
        </div>
        <div class="tabsFooter">
            <div class="tabsFooterContent"></div>
        </div>
    </div>
    @*@if (currentTabs != null && currentTabs.Count > 0)
        {
            <script>
                $(function () {
                    var objID = "div@{@currentTabs[0].ID}";
                    var url = "@{@currentTabs[0].Url}";
                    $this = $("#" + objID);
                    $this.loadUrl(url, null, function () { $this.find("[layoutH]").layoutH(); });
                });
            </script>
        }
    *@
}
